﻿namespace Chain.BLL
{
    using Chain.IDAL;
    using Chain.Model;
    using System;
    using System.Collections.Generic;
    using System.Data;

    public class GoodsAllotDetail
    {
        private readonly Chain.IDAL.GoodsAllotDetail dal = new Chain.IDAL.GoodsAllotDetail();

        public int Add(Chain.Model.GoodsAllotDetail model)
        {
            return this.dal.Add(model);
        }

        public DataSet AllotDetailByAllotID(int AllotID)
        {
            return this.dal.AllotDetailByAllotID(AllotID);
        }

        public List<Chain.Model.GoodsAllotDetail> DataTableToList(DataTable dt)
        {
            List<Chain.Model.GoodsAllotDetail> list = new List<Chain.Model.GoodsAllotDetail>();
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Chain.Model.GoodsAllotDetail item = new Chain.Model.GoodsAllotDetail();
                    if ((dt.Rows[i]["AllotDetailID"] != null) && (dt.Rows[i]["AllotDetailID"].ToString() != ""))
                    {
                        item.AllotDetailID = int.Parse(dt.Rows[i]["AllotDetailID"].ToString());
                    }
                    if ((dt.Rows[i]["AllotDetailAllotID"] != null) && (dt.Rows[i]["AllotDetailAllotID"].ToString() != ""))
                    {
                        item.AllotDetailAllotID = int.Parse(dt.Rows[i]["AllotDetailAllotID"].ToString());
                    }
                    if ((dt.Rows[i]["AllotDetailGoodsID"] != null) && (dt.Rows[i]["AllotDetailGoodsID"].ToString() != ""))
                    {
                        item.AllotDetailGoodsID = int.Parse(dt.Rows[i]["AllotDetailGoodsID"].ToString());
                    }
                    if ((dt.Rows[i]["AllotDetailNumber"] != null) && (dt.Rows[i]["AllotDetailNumber"].ToString() != ""))
                    {
                        item.AllotDetailNumber = decimal.Parse(dt.Rows[i]["AllotDetailNumber"].ToString());
                    }
                    list.Add(item);
                }
            }
            return list;
        }

        public bool Delete(int AllotDetailID)
        {
            return this.dal.Delete(AllotDetailID);
        }

        public bool DeleteAllorDetail(int AllotDetailAllotID)
        {
            return this.dal.DeleteAllorDetail(AllotDetailAllotID);
        }

        public bool DeleteList(string AllotDetailIDlist)
        {
            return this.dal.DeleteList(AllotDetailIDlist);
        }

        public bool Exists(int AllotDetailID)
        {
            return this.dal.Exists(AllotDetailID);
        }

        public DataSet GetAllList()
        {
            return this.GetList("");
        }

        public DataSet GetAllotDetailByAllotID(int AllotID)
        {
            return this.dal.GetAllotDetailByAllotID(AllotID);
        }

        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }

        public DataSet GetListSP(string strWhere)
        {
            return this.dal.GetListSP(strWhere);
        }

        public int GetMaxId()
        {
            return this.dal.GetMaxId();
        }

        public Chain.Model.GoodsAllotDetail GetModel(int AllotDetailID)
        {
            return this.dal.GetModel(AllotDetailID);
        }

        public List<Chain.Model.GoodsAllotDetail> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }

        public int GetRecordCount(string strWhere)
        {
            return this.dal.GetRecordCount(strWhere);
        }

        public bool Update(Chain.Model.GoodsAllotDetail model)
        {
            return this.dal.Update(model);
        }

        public bool Updates(Chain.Model.GoodsAllotDetail model)
        {
            return this.dal.Updates(model);
        }
    }
}

